package com.sl.plugin.step.json;

import cn.hutool.core.util.ObjectUtil;
import com.sl.core.engine.meta.ProcessCompDescriptorService;
import com.sl.core.engine.meta.impl.AbstractProcessCompDescriptor;
import com.sl.core.engine.meta.row.ProcessRowDescriptor;
import lombok.Getter;

import java.util.Map;

/**
 *
 */
@Getter
public class JsonInputCompDescriptor extends AbstractProcessCompDescriptor<
        JsonInputComp,JsonInputCompContext> implements ProcessCompDescriptorService {


//    @Override
//    protected ProcessCompService getComp() {
//        return new JsonInputComp(this);
//    }
//
//    @Override
//    public ProcessCompContextService getContext() {
//        return new JsonInputCompContext();
//    }

    @Override
    public void loadDescriptor(Map<String, Object> map) {
        //输入定义
        Map<String, Object> inputJsonDefine = getJsonDefine("input");

        buildInputProcessRowDescriptor(inputJsonDefine);
        //标记是开始
        setIsStartStep(true);
    }


    @Override
    public ProcessRowDescriptor getResultDescriptor(ProcessRowDescriptor rowDescriptor) {
        ProcessRowDescriptor rowMeta = getInputRowDescriptor();
        if (ObjectUtil.isNull(rowMeta) || rowMeta.isEmptyAndNotBasic()) {
            return rowDescriptor;
        }
        return rowMeta;
    }

}
